import { fetch } from './http';

export const login = () => fetch('web/api/user/login', {}, 'GET', {withMask: false});
export const getUserId = id => fetch(`/web/api/token/${id}`, {}, 'GET', {withMask: false});
export const getUserInfo = (id, withMask = true) => fetch(`web/api/${id}/user`, {}, 'GET', {withMask});
export const setUserInfo = (userId, params, withMask = true) => fetch(`web/api/user/${userId}/update`, params, 'POST', {withMask, headers: {'Content-Type': 'application/x-www-form-urlencoded'}});
export const getChapterList = (state, withMask = true) => fetch(`web/api/course/chapter/list`, {state}, 'GET', {withMask});
export const getLessonList = (chapterId, withMask = true) => fetch(`web/api/course/lesson/list`, {chapterId}, 'GET', {withMask});
export const getClassroom = (userId, withMask = true) => fetch(`web/api/user/${userId}/advanced/classroom`, {}, 'GET', {withMask});
export const getCourses = (id, withMask = true) => fetch(`/web/api/user/${id}/courses`, {}, 'GET', {withMask});
export const getContract = (id, withMask = true) => fetch(`web/api/user/${id}/contract`, {}, 'GET', {withMask});
export const getTestList = (userId, withMask) => fetch(`web/api/problem/list/${userId}`, {}, 'GET', {withMask});
export const uploadContract = (id, data, withMask = true) => fetch(`web/api/set/user/${id}/contract`, data, 'POST', {withMask, headers: {'Content-Type': 'multipart/form-data'}});
